package com.qianli.cashmama.trade.client.trade.request;

import com.fqgj.common.api.ParamsObject;
import com.fqgj.exception.common.ApplicationException;
import org.apache.commons.lang.StringUtils;

/**
 * Created with IntelliJ IDEA.
 * User: sm
 * Date: 2017/7/31
 * Time: 下午9:34
 */
public class QueryUserLatestTradeRequest extends ParamsObject {
    private String userCode;

    private String productCategory;

    /**
     * 是否展示交易状态历史
     */
    private boolean showStatusHistory = false;


    public QueryUserLatestTradeRequest(String userCode, String productCategory, boolean showStatusHistory) {
        this.userCode = userCode;
        this.productCategory = productCategory;
        this.showStatusHistory = showStatusHistory;
    }

    public QueryUserLatestTradeRequest(String userCode, String productCategory) {
        this.userCode = userCode;
        this.productCategory = productCategory;
    }

    public boolean isShowStatusHistory() {
        return showStatusHistory;
    }

    public String getUserCode() {
        return userCode;
    }

    public String getProductCategory() {
        return productCategory;
    }

    @Override
    public void validate() {
        if (StringUtils.isEmpty(userCode)) {
            throw new ApplicationException("Parameter error");
        }

        if (StringUtils.isEmpty(productCategory)) {
            productCategory = null;
        }
    }
}
